package edu.pku.sei.transformation.compositeengine.testengine;

import edu.pku.sei.transformation.editor.model.execution.Pin;
import edu.pku.sei.transformation.editor.model.execution.TransformationExecution;
import edu.pku.sei.transformation.engine.EngineExtraData;
import edu.pku.sei.transformation.engine.IEngineAdapter;
import edu.pku.sei.transformation.engine.IEngine;
import edu.pku.sei.transformation.execution.ExecutionEnvironment;

public class TestEngineAdapter implements IEngineAdapter {

	@Override
	public EngineExtraData getExtraData(EngineExtraData oringin) {
		return null;
	}

	@Override
	public String getID() {
		return "testEngine";
	}

	@Override
	public IEngine getRunner(TransformationExecution execution,
			ExecutionEnvironment env) throws Exception {
		String name = execution.getName()+":"+execution.getTransformation().getName();
		String input = "";
		String output = "";
		for (Pin p : execution.getActualParameters()) {
			if (p.getFormalParameter() == execution.getDirection()) {
				output = env.getPath(p);
			} else {
				input = env.getPath(p);
			}
		}
		TestEngineRunner runner = new TestEngineRunner(name, input, output);
		return runner;
	}

}
